package com.example.demo.leetcode.classics150;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname _36旋转图像
 * @description
 * @date 2023/07/19 17:05
 * <p>
 * ******************************************************
 */
public class _36旋转图像 {

    public void rotate(int[][] matrix) {

        int n = matrix.length;
        int temp;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }

        for (int i = 0; i < n; i++) {
            int l = 0; int r = n-1;
            while (l < r) {
                temp = matrix[i][l];
                matrix[i][l] = matrix[i][r];
                matrix[i][r] = temp;
                l++;
                r--;
            }
        }

    }
}
